#include<iostream>
using namespace std;

int fibonacci(int n){
    if(n<=1){
        return n;
    }
    int *fib=new int[n+1];
    fib[0]=0;
    fib[1]=1;
    for(int i=2;i<=n;i++){
        fib[i]=fib[i-1]+fib[i-2];
        cout<<fib[i]<<endl;
    }

    int result=fib[n];
    delete[] fib;
    return result;

}
int main(){
    int n=9;
    int res=fibonacci(n);
    cout<<"\nf("<<n<<")="<<res<<endl;
    return 0;
}